<template>
   <div class="advers">
    <div class="body-top" v-for="(index, item) in advertList" track-by="$index">
        <advert-item :content.sync="item" :mcht-name-options="mchtNameOptions" @is-change="isChange"></advert-item>
        <div class="rule-btn">
          <v-button class="pull-right" v-show = "advertList.length === 1?false:true" theme="danger" @click="remove(index)">删除</v-button>
         </div>
    </div>
    <div>
          <v-button theme="primary" @click="add">添加</v-button>
    </div>    
  </div>
</template>
<style lang="less" scoped>
.advers {
  width: 100%;
  height: 100%;
  border: 1px solid #d2d6de;
  border-top: 3px solid #d2d6de;
  box-sizing: border-box;
  padding: 10px;
  border-radius: 3px;
}
.body-top {
  width: 100%;
  border: 1px solid #d2d6de;
  box-sizing: border-box;
  padding: 10px;
  margin-bottom: 10px;
  .rule-btn {
    width: 100%;
    overflow: hidden;
    &:after {
      content: "";
      clear: both;
    }
  }
}
.addRule {
  display: inline-block;
  padding: 0 10px;
  text-align: center;
  line-height: 34px;
  color: #fff;
  background: #3c8dbc;
  border-radius: 4px;
  margin-top: 2px;
  font-size: 14px;
}
</style>
<script>
import AdvertItem from "./advert.item";
export default {
  components: {
    AdvertItem
  },
  props: {
    advertList: {
      type: Array,
      require: true
    },
    mchtNameOptions: {
      type: Array
    }
  },
  methods: {
    add() {
      this.$emit("add-advert");
    },
    remove(index) {
      this.$emit("remove-advert", index);
    },
    isChange (content) {
      this.$emit('is-change',content)
    }
  }
};
</script>



